package com.yidu.ruifeng_logistics.service.impl;

import com.yidu.ruifeng_logistics.entity.LogisticsStorage;
import com.yidu.ruifeng_logistics.dao.LogisticsStorageDao;
import com.yidu.ruifeng_logistics.service.LogisticsStorageService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (LogisticsStorage)表服务实现类
 *
 * @author makejava
 * @since 2021-03-09 14:29:23
 */
@Service("logisticsStorageService")
public class LogisticsStorageServiceImpl implements LogisticsStorageService {
    @Resource
    private LogisticsStorageDao logisticsStorageDao;

    /**
     * 通过ID查询单条数据
     *
     * @param storageId 主键
     * @return 实例对象
     */
    @Override
    public LogisticsStorage queryById(Integer storageId) {
        return this.logisticsStorageDao.queryById(storageId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<LogisticsStorage> queryAllByLimit(int offset, int limit) {
        return this.logisticsStorageDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param logisticsStorage 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsStorage insert(LogisticsStorage logisticsStorage) {
        this.logisticsStorageDao.insert(logisticsStorage);
        return logisticsStorage;
    }

    /**
     * 修改数据
     *
     * @param logisticsStorage 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsStorage update(LogisticsStorage logisticsStorage) {
        this.logisticsStorageDao.update(logisticsStorage);
        return this.queryById(logisticsStorage.getStorageId());
    }

    /**
     * 通过主键删除数据
     *
     * @param storageId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer storageId) {
        return this.logisticsStorageDao.deleteById(storageId) > 0;
    }

    @Override
    public List<LogisticsStorage> queryAll(LogisticsStorage logisticsStorage) {
        return this.logisticsStorageDao.queryAll(logisticsStorage);
    }

    @Override
    public int deleteAll(String ids) {
        String[] s = ids.split(",");
        return logisticsStorageDao.deleteAll(s);
    }

}
